package com.grandt.model.database.manager;

import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.List;

import com.grandt.model.beans.usuarios.Contacto;
import com.grandt.model.configuration.ConfigurationBean;

public class DataBaseContacto extends ManagerDataBase {

	public DataBaseContacto(ConfigurationBean configuration) {
		super(configuration);
	}

	public void insertSinCommit(Object object) throws  SQLException{

			String query = getStrInsert();
			PreparedStatement prst;
			prst = connection.prepareStatement(query);
			insertParameters(prst,object);
			prst.execute();
	}

	@Override
	protected String getStrInsert() {
		String query="INSERT INTO CONTACTO(PROVINCIA,PARTIDO,LOCALIDAD,CALLE,NUMERO,PISO," +
				"DEPARTAMENTO,CODIGO_POSTAL,NUMERO_TELEFONO,NUMERO_CELULAR,COMPANIA_CELULAR,EMAIL)" +
				" VALUES (?,?,?,?,?,?,?,?,?,?,?,?)";
		return query;
	}
	
	@Override
	protected void insertParameters(PreparedStatement prst,Object o) throws SQLException {		
		
		Contacto contacto = (Contacto) o;
		prst.setString(1, contacto.getProvincia());
		prst.setString(2, contacto.getPartido());
		prst.setString(3, contacto.getLocalidad());
		prst.setString(4, contacto.getCalle());
		prst.setInt(5, contacto.getNumero());
		prst.setString(6, contacto.getPiso());
		prst.setString(7, contacto.getDepartamento());
		prst.setString(8, contacto.getCodigoPostal());
		prst.setString(9, contacto.getNroTelefono());
		prst.setString(10, contacto.getNroCelular());
		prst.setString(11, contacto.getCiaCelular());
		prst.setString(12, contacto.getEmail());
	}

	@Override
	protected List<Object> getResult(ResultSet result) {
		return null;
	}

	@Override
	protected String getStrQuery() {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	protected void queryParameters(PreparedStatement prst, Object o) {
		// TODO Auto-generated method stub
		
	}
}
